package com.yimi.yinhepda.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 项目名称：YinHePda
 * 创建时间：2017/3/23 15:26
 * 版本号：1.0
 * 功能描述 条码规则类
 *
 * @author 刘宏恩
 */
public class BarCodeRules {
    /**
     * 配载单号校验规则
     * “P+年月日6位+5位流水”例“P16112400001”
     */
    public static boolean carCodeCheck(String carCode) {
//    String check = "(?i)^P[0-9]{2}(0[1-9]|1[0-2])(0[1-9]|[1][0-9]|2[0-9]|3[0-1])\\d{5}$";
//    Pattern regex = Pattern.compile(check);
//    Matcher matcher = regex.matcher(carCode);
//    return matcher.matches();
        return true;
    }

    /**
     * 子单号验证规则
     */
    public static boolean childWaybillNoCheck(String childWaybillNo) {
        String check = "^[1-9]{1}[0-9]{14}$";
        Pattern regex = Pattern.compile(check);
        Matcher matcher = regex.matcher(childWaybillNo);
        return matcher.matches();
    }

    /**
     * 主单号验证规则
     */
    public static boolean waybillNoCheck(String waybillNo) {
        String check = "^[1-9]{1}[0-9]{11}$";
        Pattern regex = Pattern.compile(check);
        Matcher matcher = regex.matcher(waybillNo);
        return matcher.matches();
    }
}
